import turtle
import random



def gen_points():
    for i in range(5):
        y = random.randint(-300, 300)
        x = 300
        points.append([x,y])
    turtle.ontimer(gen_points, 4000)

def goto(pos):
    """画笔抬起移动"""
    turtle.up()
    turtle.goto(pos)
    turtle.down()

def move():
    turtle.clear()
    for i in range(len(points)):
        point = points[i]
        goto(point)
        turtle.dot(30, 'cyan')
        points[i][0]-=10
    draw_star()
    turtle.ontimer(move, 400)

def main():
    gen_points()
    move()

def draw_star():
    goto(star)
    turtle.fillcolor('green')
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(50)
        turtle.right(144)
    turtle.end_fill()
star = [0,0]
points = []
turtle.tracer(False)
main()
turtle.done()
